create or replace function calculate(
    in x double precision,
    in y double precision,
    out sum double precision
) returns double precision as
              $$
begin
    sum = x + y;
end;
$$
language plpgsql;

create or replace function get_person(personId integer) returns refcursor as
              $$
              declare persons refcursor;
begin
    open persons for select id,first_name,last_name,phone,address from person where id = personId;
return persons;
end;
$$
    language plpgsql;


create or replace function get_all_persons() returns refcursor as
              $$
              declare persons refcursor;
begin
    open persons for select * from person;
return persons;
end;
$$
language plpgsql;